<template>
  <div>
    <div class="main">
      <van-field
        readonly
        class="input_text"
        name="ChnName"
        v-model="form.ChnName"
        label="姓名"
        required
      >
      </van-field>
      <!-- <van-field label="身份证号" v-model="form.CardNo" name="CardNo" required>
      </van-field> -->

      <van-field
        readonly
        class="input_text"
        name="CardNo"
        v-model="form.CardNo"
        label="身份证号"
        required
      >
      </van-field>

      <van-field
        readonly
        class="input_text"
        name="SocialSecurityNo"
        v-model="form.SocialSecurityNo"
        label="社保编号"
      >
      </van-field>

      <van-field
        readonly
        class="input_text"
        name="form.LeaveDate"
        v-model="form.LeaveDate"
        label="离职日期"
      >
      </van-field>

      <van-field
        readonly
        class="input_text"
        name="form.SocialSecurityDate"
        v-model="form.SocialSecurityDate"
        label="参保日期"
      >
      </van-field>

      <van-field class="input_text" name="radio" label="员工状态" required>
        <template #input>
          <van-radio-group
            direction="horizontal"
            v-model="form.EmpStatus"
            disabled
          >
            <template v-for="(item, index) in form.EmpStatusList">
              <van-radio :name="item.ID" :key="index">{{
                item.Name
              }}</van-radio>
            </template>
          </van-radio-group>
        </template>
      </van-field>


      <van-field
        readonly
        class="input_text"
        name="form.BaseSalary"
        v-model="form.BaseSalary"
        label="缴费基数"
      >
      </van-field>
    </div>
  </div>
</template>

<script>
import {
  SiteInjuryRecordGetDetail,
} from "@/api/SiteSafeCost";
import { formatDate, getDate, getTime } from "@/utils/getDate";
import { mapGetters } from "vuex";
import store from '@/store/index'

export default {
  components: {

  },
  data() {
    return {
      id: this.$route.query.id,
      radio: "1",
      form: {},
    };
  },

  computed: {
    ...mapGetters(["baseUrl", "CompanyCode", "roles"]),
  },

  created() {
    if (this.$route.query.id != null) {
      (this.id = this.$route.query.id), this.getDetail();
    }

    // const nowDate = new Date();
    // var year = nowDate.getFullYear();
    // var years = [];

    // for (var index = 10; index > 0; index--) {
    //   var curyear = year - index;
    //   console.log("curyear -", curyear);
    //   years.push(curyear.toString());
    // }

    // for (var index = 0; index < 10; index++) {
    //   var curyear = year + index;
    //   console.log("curyear +", curyear);
    //   years.push(curyear.toString());
    // }

    // this.yearList = years;
    // ["2011","2012","2013","2014","2015","2016","2017","2018","2019","2020","2021","2022","2023","2024"];

    console.log("id", this.$route.query.id);

    //this.getDistList();
  },
  activated() {
    // if (this.$route.params.certFile) {
    // 	this.fileList.push({
    // 		AttCode: this.$route.params.certFile.AttCode,
    // 		AttExt: this.$route.params.certFile.AttExt,
    // 		AttName: this.$route.params.certFile.AttName,
    // 	})
    // }
    //将该页面的id和新获取的id进行比对，如果不一致，说明页面应该进行数据刷新
    //重新请求数据
    // if (this.$route.params.userlist) {
    //   const userlist = this.$route.params.userlist;
    //   let EquManagerChnName = [];
    //   let EquManagerUserName = [];
    //   userlist.forEach((item) => {
    //     EquManagerChnName.push(item.name);
    //     EquManagerUserName.push(item.code);
    //   });
    //   this.form.EquManagerChnName = EquManagerChnName.join(",");
    //   this.form.EquManagerUserName = EquManagerUserName.join(",");
    // }
  },

  methods: {


    getDetail(certId) {
      let params = { id: this.id };

      
        SiteInjuryRecordGetDetail(params).then((res) => {
          // res.data.PublishDate = getTime(res.data.PublishDate)
          // res.data.ReviewDate = getTime(res.data.ReviewDate)
          // res.data.NextReviewDate = getTime(res.data.NextReviewDate)

          // this.fileList = [];

          if (res.data.Attachs) {
            let Attachs = res.data.Attachs.split(";");
            console.log(Attachs, "Attachs");
            res.data.Attachs = JSON.parse(res.data.Attachs);
          } else {
            res.data.Attachs = [];
          }
          this.form = res.data;
          this.form.LeaveDate = getDate(this.form.LeaveDate);
          this.form.SocialSecurityDate = getDate(this.form.SocialSecurityDate);
        });
    },

  },
};
</script>

<style lang="less" >
.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.block {
  width: 120px;
  height: 120px;
  background-color: #fff;
}
</style>
<style lang="less" scoped>
.space-between {
  justify-content: space-between;
}
</style>
